import service from '../internal/service'
const querystring = require('querystring')

// 客群管理3张表格的数据接口
export function APIGetShopStatus (shopId, date = '') {
  return service({
    url: `/api/shops/${shopId}/customer-charts/?date=${date}`,
    method: 'get'
  })
}

// 客群管理2个数据 + 第一个 表格
export function APIDailyStatus (shopId, date = '') {
  return service({
    url: `/api/shops/${shopId}/daily-stats/?date=${date}`,
    method: 'get'
  })
}
// 用户画像数据接口
export function APICustomers ({ shopId, date = '', page = 1, pagesize = 10 }) {
  return service({
    url: `/api/shops/${shopId}/customers/?date=${date}&page=${page}&page_size=${pagesize}`,
    method: 'get'
  })
}
// 顾客信息
/**
 * [APICustomersInfo description]
 * @param       {[type]} shopId   [description]门店id
 * @param       {[type]} customerId [description]顾客id
 * @constructor
 */
export function APICustomersInfo ({shopId, customerId}) {
  return service({
    url: `/api/shops/${shopId || ''}/customers/${customerId}`,
    method: 'get'
  })
}

export function APIGetUserAvatarList ({ shop, params }) {
  params = params || { page: 1, page_size: 10 }
  return service({
    url: `/api/shops/${shop}/customers/?&${querystring.encode(params)}`,
    method: 'get'
  })
}

export function APIGetUserInfoById ({ shop, customer, lineId }) {
  return service({
    url: `/api/shops/${shop}/customers/${customer}/lines/${lineId}`,
    method: 'get'
  })
}

export function APIGetUserHistoryRecById ({ shop, customer, page = 1 }) {
  return service({
    url: `/api/shops/${shop}/customers/${customer}/visit-list?page=${page}`,
    method: 'get'
  })
}
